import { request } from "@/network/request";

// 样例,会了就删了
export function getMessage(goods) {
  return request({
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/home/data", // url地址后缀完整的在外部
    params: {
      goodsId: goods.goodsId,
      goodsTitle: goods.goodsTitle,
      goodsInfo: goods.goodsInfo,
      price: Number.parseFloat(goods.price),
      goodsImg: goods.goodsImg,
      goodsNum: goods.goodsNum
    },
    headers: {
      // 头文件封装
      Authorization: sessionStorage.getItem("userToken"),
      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

//个人信息认证
export function setInsertPAI(form) {
  return request({
    baseURL: "/identity",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/personal/certificate/insertPAI", // url地址后缀完整的在外部
    data: {
      username: form.username,
      real_name: form.name,
      id_type: form.id_type,
      id_number: form.number,
      id_photo: form.photo,
      id_validity: form.validity,
      contact_email: form.email,
      contact_address: form.address
    },
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
export function getPv(username) {
  return request({
    baseURL: "/identity",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/personal/certificate/pv/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

// url,nickname,username,point,gender,email,mobile,password,achievement1,achievement2,achievement3,achievement4

export function getMyInfo() {
  return request({
    baseURL: "/api",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/query", // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getPoint() {
  return request({
    baseURL: "/api",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/details", // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getModifyInfo(nickname, gender, email, mobile) {
  return request({
    baseURL: "/api",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/modifyInfo", // url地址后缀完整的在外部
    params: {
      nickname: nickname,
      gender: gender,
      email: email,
      mobile: mobile
    },
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getPassword(password) {
  return request({
    baseURL: "/api",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/password", // url地址后缀完整的在外部
    params: {
      password: password
    },
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getModpassword(password) {
  return request({
    baseURL: "/api",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/modpassword", // url地址后缀完整的在外部
    params: {
      password: password
    },
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function setHeadImg(file) {
  return request({
    timeout: 10000,
    baseURL: "/apih",
    method: "POST", // 发送方法 GET POST DELETE PUT
    url: "/sys/user/lr/upload", // url地址后缀完整的在外部
    data: file,
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "multipart/form-data"
    }
  });
}

export function getCrowdFundingListByuserName() {
  return request({
    baseURL: "/crowd",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/getCrowdFundingListByuserName", // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getParticipateCrowdFundingListByuserName() {
  return request({
    baseURL: "/crowd",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/crowdfunding/crowdFunding/getParticipateCrowdFundingListByuserName", // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getListByUserName(username) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/donation/base/getBasicByUserName/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getByUserName(username) {
  return request({
    baseURL: "/msglen",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/donation/donationthings/getByUserName/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getAlreadyOrdersByUsername(username) {
  return request({
    baseURL: "/apiorder",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/order/getAlreadyOrdersByUsername/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getCancelOrdersByUsername(username) {
  return request({
    baseURL: "/apiorder",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/order/getCancelOrdersByUsername/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getNonePayOrdersByUsername(username) {
  return request({
    baseURL: "/apiorder",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/order/getNonePayOrdersByUsername/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getNoneReceiveOrdersByUsername(username) {
  return request({
    baseURL: "/apiorder",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/order/getNoneReceiveOrdersByUsername/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function getNoneSendOrdersByUsername(username) {
  return request({
    baseURL: "/apiorder",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: "/order/getNoneSendOrdersByUsername/" + username, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

export function deleteOrderByOrderId(orderId) {
  return request({
    baseURL: "/apiorder",
    method: "DELETE", // 发送方法 GET POST DELETE PUT
    url: `/order/deleteOrderByOrderId/${orderId}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}

//通知
export function getFb(username) {
  return request({
    baseURL: "/identity",
    method: "GET", // 发送方法 GET POST DELETE PUT
    url: `/audit/feedback/fb/${username}`, // url地址后缀完整的在外部
    headers: {
      // 头文件封装
      token: sessionStorage.getItem("userToken"),

      // 格式设置
      "Content-Type": "application/json"
    }
  });
}
